module.exports = (sequelize, DataTypes) => {
  const brands = sequelize.define(
    'brands',
    {
      id: {
        type: DataTypes.INTEGER(11),
        primaryKey: true,
        autoIncrement: true
      },
      brandName: {
        type: DataTypes.STRING(255),
        allowNull: false,
        field: "brand-name"
      }
    },
    {
      tableName: 'brands',
      timestamps: false,//使用事务时，出现Unknown column 'created_at' in 'field list'，原因是sequelize默认会自动为其添加 createdAt 和updatedAt column值，添加timestamp处理
    },
  )

  brands.associate = (models) => {//定义外键关联
    brands.belongsTo(
      models.electric_sale,
      {foreignKey: 'id'}
    );
  }
  return brands;
};